package 设计模式;

public class SingletonDemo4 {

    private volatile static SingletonDemo4 instance = null;
    private SingletonDemo4(){}

    public static SingletonDemo4 getInstance(){
        if(instance==null){
            synchronized (SingletonDemo4.class){
                if(instance==null){
                    instance = new SingletonDemo4();
                }
            }
        }
        return instance;
    }
}
